<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>

    #bootstrap-table tr:nth-child(even) {
        background: transparent !important;
    }

    #bootstrap-table th {
        background: transparent !important;
    }

    #bootstrap-table a {
        width: 100%;
        height: 100%;
        display: block;
        color: #000000;
    }

    #bootstrap-table a:hover {
        color: #000000;
    }

    #bootstrap-table a:visited {
        color: #000000;
    }

    #bootstrap-table a:active {
        color: #000000;
    }
</style>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <h1>安装进度查看</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline" style="padding-left: 15px">
                                <!--<input th:value="${prodOrd.prodNo}" name="prodNo" style="display: none" type="hidden"/>-->
                                <input th:value="${prodOrd.prodNo}" name="proCode" style="display: none" type="hidden"/>
                            </div>
                        </div>
                    </form>
                </div>
                <div id="toolBar">
                    <div class="row">
                        <div class="form-inline">
                            <div class="form-group">
                                <label>项目编号：</label>
                                <label th:text="${prodOrd.prodNo}"></label>
                            </div>
                            <div class="form-group">
                                <label>项目名称：</label>
                               <label th:text="${project.proName}"></label>-->
                            </div>
                            <div class="form-group">
                                <label>数量：</label>
                                <label th:text="${prodOrd.prodNum}"></label>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;
    var tableExplain;
    var statusName = ["不需要", "未开始", "执行中", "已完成"];
    var classType = ["label-primary", " label-default", " label-warning", " label-success"];
    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "create/dispatching/installList",
            showExport: false,
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "生产令号", field: 'proCode', width: '100'},
                {title: "项目名称", field: 'proName', width: '280'},
                {title: "订单数量", field: 'prodNum', width: '80'},
                {title: "安装地点", field: 'installPlace', width: '280'},
                {title: "需方", field: 'customer', width: '280'},
                {title: "创建日期", field: 'authorTime', width: '280'},
                {
                    title: "状态", field: 'installStatu', width: '80',
                    formatter: function (value) {
                        return '<span class="badge' + classType[value] + '">' + statusName[value] + '</span>';
                    }
                }
            ]
        });

        initChildTable = function (index, row, $detail) {
            let childTable = $detail.html('<table  style="table-layout:fixed"></table>').find('table');
            $(childTable).bootstrapTable({
                url: ctx + "create/dispatching/installDetail",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams: {
                    sheetId: row.id,
                },
                responseHandler: function (res) {
                    if (res.type === "SUCCESS") {
                        return res.data;
                    }
                    js.modal.warning(res.msg);
                    return {rows: [], total: 0};
                },
                columns: [
                    {
                        title: '序号', width: '50',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {
                        field: 'special',
                        title: '类型'
                    },
                    {
                        field: 'installStartTime',
                        title: '开始时间'
                    },
                    {
                        field: 'installStatus',
                        title: '安装进度',
                        formatter: function (value) {
                            return '<span class="badge' + classType[value] + '">' + statusName[value] + '</span>';
                        }
                    },
                    {
                        field: 'installEndTime',
                        title: '结束时间'
                    },
                    {
                        field: 'installName',
                        title: '操作者'
                    },
                    {
                        field: 'installDuringRemark',
                        title: '备注'
                    },

                    {
                        title: "附件", width: '150',
                        formatter: function (value, row) {
                            let actions = [];
                            actions.push('<span> 文件数:' + row.expCount + '</span> ');

                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openExplain(' + js.jsonStringify(row) + ')"> 文件</a> ');

                            return actions.join('');
                        }
                    }
                ]
            });
        };
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
    });

    /**
     * 重新加载
     */
    function reLoad() {
        js.table.refresh(table);
    }

    /**
     * 查看
     */
    function viewInfo(id) {
        window.open(ctx + 'task/assemblySheetListView/detail/' + id);
    }
</script>
</body>
</html>